/*
 * UIText.h
 */

#ifndef UITEXT_H_
#define UITEXT_H_

#include "UILeaf.h"
#include <string>
#include <GL/gl.h>
#include <GL/glu.h>

/**
 * UI Component used to render text in OpenGL context
 */
class UIText: public UILeaf {
public:
  /**
   * Type of the UI Text component
   */
  enum TextType {
    TITLE, STDTEXT
  };

  /**
   * Constructor
   * @param type type of the UI Text Component
   * @param x x-coordinate of the text (relative to its parent container)
   * @param y y-coordinate of the text (relative to its parent container)
   * @param height height of the text to be rendered
   * @param angle angle of rotation (relative to its parent)
   * @param text data characters to be rendered
   * @param color color used when rendering the text
   */
  UIText(UIText::TextType type, float x, float y, float height, float angle,
      std::string text, RGBAColor color);

  /**
   * Destructor
   */
  virtual ~UIText();

  /**
   * Draws the text in the current OpenGL context
   */
  virtual void draw();

  /**
   * Replaces the actual text
   * @param text new text to be rendered
   */
  bool set(std::string& text);

  //float static getTextSize(UIText::TextType type, std::string& text);

protected:
  /**
   * Initializes the TrueType Font support in the SDL library
   */
  void initSDLTTFSupport();

  /**
   * Ends the TrueType Font support in the SDL library
   */
  void quitSDLTTFSupport();

protected:
  /**
   * Mode of the UI Text Component
   */
  TextType _mode;

  /**
   * angle of rotation
   */
  int _angle;

  /**
   * text to be displayed
   */
  std::string _text;

  /**
   * color used when rendering the text
   */
  RGBAColor _color;

  /**
   * OpenGL texture ID to render the text
   */
  GLuint _tex;
};

#endif /* UITEXT_H_ */
